package com.example.mercury.utils;

import com.example.mercury.entity.Register;
import com.example.mercury.entity.User;
import com.google.gson.Gson;

/**
 * @author 盛守义
 * @createTime 2021/10/25 11:19
 * @projectName TurningCoffee
 * @className JsonUtils.java
 * @description TODO
 */
public class JsonUtils {

    public String toJsonString(User user){
        Gson gson = new Gson();
        String jsonString = gson.toJson(user);
        return jsonString;
    }

    public Register getRegister(String res){
        Register register = new Register();
        Gson gson = new Gson();
        register = gson.fromJson(res, Register.class);
        return register;
    }
}
